package com.baijia.util;

public final class SecretCoverUtil {

    private final static String MOBILE_COVER_PATTERN = "(?<=\\d{3})\\d(?=\\d{3})";

    private SecretCoverUtil() {

    }

    /**
     * 手机号的中间4位替换成*
     * 
     * @param mobile
     * @return
     */
    public static String coverMobileWithAsterisk(String mobile) {
        return coverSecret(mobile, MOBILE_COVER_PATTERN, "*");

    }

    public static String coverSecret(String oriString, String pattern, String replacement) {
        return oriString.replaceAll(pattern, replacement); // FIXME 校验不够
    }

}
